#include <iostream>

using std::cout;
using std::endl;

int func()
{
    cout << "int func()" << endl;
    return 10;
}

int func2()
{
    cout << "int func2()" << endl;
    return 20;
}

int add(int x, int y)
{
    cout << "int add(int, int)" << endl;
    return x + y;
}

void test()
{
    func();
    typedef int (*pFunc)();//函数指针//C中的写法
    /* typedef int(*)() pFunc;//error */
    /* using pFunc = int(*)();//ok, C++中是可以的 */
    /* typedef int A; */
    /* using A = int; */

    //延迟调用函数
    pFunc f = &func;//回调函数进行注册（注册回调函数）
    //...
    //...
    //...
    cout << "f() = " << f() << endl;//回调的函数执行

    cout << endl;
    f = func2;
    cout << "f() = " << f() << endl;

    cout << endl;
    /* f = add;//error,add函数的形态与f的形态不一致 */
   
}

int main(int argc, char *argv[])
{
    test();
    return 0;
}

